import axios from 'axios'
import { defineStore } from 'pinia'
import { ArtListRes, ArtListType } from '../../types/data'

const userArtStore = defineStore('art', {
  state() {
    return {
      artList: [] as ArtListType,
    }
  },

  actions: {
    async getArtList(id: number) {
      const res = await axios.get<ArtListRes>(
        `http://geek.itheima.net/v1_0/articles?channel_id=${id}&timestamp=${Date.now()}`
      )
      console.log(res.data.data.results)

      this.artList = res.data.data.results
    },
  },
  getters: {},
})

export default userArtStore
